package com.yequan.leetcode.array.longestpalindrome;

/**
 * @author : Administrator
 * @date : 2020/3/19
 */
public class RecodeLongestPalindrome {

    public int longestPalindrome1(String s) {
        int[] countArray = new int[58];
        s.chars().forEach(c -> ++countArray[c - 'A']);

        int length = 0;

        for (int count : countArray) {
            length += count - (count & 1);
        }
        return length < s.length() ? length + 1 : length;
    }

    public int longestPalindrome2(String s) {
        int[] countArray = new int[58];
        s.chars().forEach(c -> ++countArray[c - 'A']);

        int length = 0;

        for (int count : countArray) {
            length += count - (count & 1);
        }
        return length < s.length() ? length + 1 : length;
    }

    public int longestPalindrome3(String s) {
        int[] countArray = new int[58];
        s.chars().forEach(c -> ++countArray[c - 'A']);

        int length = 0;

        for (int count : countArray) {
            length += count - (count & 1);
        }
        return length < s.length() ? length + 1 : length;
    }

    public int longestPalindrome4(String s) {
        int[] countArray = new int[58];
        s.chars().forEach(c -> ++countArray[c - 'A']);

        int length = 0;

        for (int count : countArray) {
            length += count - (count & 1);
        }
        return length < s.length() ? length + 1 : length;
    }

    public int longestPalindrome5(String s) {
        int[] countArray = new int[58];
        s.chars().forEach(c -> ++countArray[c - 'A']);

        int length = 0;

        for (int count : countArray) {
            length += count - (count & 1);
        }
        return length < s.length() ? length + 1 : length;
    }

    public int longestPalindrome6(String s) {
        int[] charArray = new int[58];
        s.chars().forEach(c -> ++charArray[c - 'A']);

        int length = 0;

        for (int count : charArray) {
            length += count - (count & 1);
        }
        return length < s.length() ? length + 1 : length;
    }
}
